<template>
  <view class="custom-nav" :style="{ top: top + 'px', height: height + 'px' }">
    <view class="custom-back" v-if="hasBackBtn" @click="goBack">
      <up-icon name="arrow-left" :color="themeColor" size="22"></up-icon>
    </view>
    <view class="custom-title" :style="{ color: themeColor }">{{ title }}</view>
  </view>
</template>

<script>
export default {
  name: "custom-nav",
  data() {
    return {
      height: 60,
      top: 44,
    };
  },
  props: {
    title: {
      type: String,
      default: "",
    },
    hasBackBtn: {
      type: Boolean,
      default: true,
    },
    themeColor: {
      type: String,
      default: "#fff",
    },
  },
  created() {
    // #ifdef MP-WEIXIN
    let { height, top } = wx.getMenuButtonBoundingClientRect(); // 胶囊状态信息
    this.height = height;
    this.top = top;

    // #endif
  },
  methods: {
    handleBack() {
		console.log(22222)
      uni.navigateBack()
    },
  },
};
</script>

<style lang="less" scoped>
.custom-nav {
  position: absolute;
  width: 100vw;
  height: 200rpx;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;

  .custom-back {
    position: absolute;
    left: 20rpx;
    top: 12rpx;
    width: 100rpx;
    vertical-align: middle;
  }

  .custom-title {
    position: relative;
    font-size: 36rpx;
    // color: #fff;
    font-weight: 600;
  }
}
</style>
